package com.example.demo.servlet;

import org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "test", urlPatterns = "/test")
public class TestServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //super.doGet(req, resp);
        String value = req.getParameter("value");

        HttpSession session = req.getSession();
        session.setAttribute("value", value);

        // 方式一
        PrintWriter writer = resp.getWriter();
        writer.println("add value:" + value);

        resp.getOutputStream();
    }
}
